

// import '../Role_management/roleNew.scss'
import '../../static/font/iconfont.css'
import { Form, Input, Button, Select, Modal, DatePicker } from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import http from '../../utils/http'
const { Option } = Select;
const { confirm } = Modal;
const layout = {
    labelCol: {
        span: 6,
    },
    wrapperCol: {
        span: 14,
    },
};
const tailLayout = {
    wrapperCol: {
        offset: 10,
        span: 16,
    },
};
const OrgNew = ({ setState }) => {
    //返回页面
    const backCar = () => {
        setState(1)
    }
    const quxiao = () => {
        confirm({
            icon: <ExclamationCircleOutlined />,
            content: '您确定离开此页面吗？',
            cancelText: '取消',
            okText: '确定',
            onOk() {
                //   console.log('OK');
                backCar()
            },
            onCancel() {
                console.log('Cancel');
            },
        });
    }
    const [form] = Form.useForm();
    const onFinish = (values) => {
        let createtime;
        if (values.orCreatetime) {
            let date = new Date(values.orCreatetime)
            let y = date.getFullYear()  //获取年份
            let m = date.getMonth() + 1  //获取月份
            m = m < 10 ? "0" + m : m  //月份不满10天显示前加0
            let d = date.getDate()  //获取日期
            d = d < 10 ? "0" + d : d  //日期不满10天显示前加0
            createtime = y + "-" + m + "-" + d;
        }
        values.orCreatetime = createtime
        console.log(values);
        // console.log(createtime);
        http({
            url: '/orgmanage/addOrgManage',
            method: 'post',
            data: values
        }).then((res) => {
            console.log(res)
        })
        form.resetFields();
    };
    return <div className="xinzeng">
        <div>
            <div className='tit'>
                <div>
                    <div>
                        <div></div>
                        <div>组织管理新增</div>
                    </div>
                </div>
                <div>
                    <span className="iconfont icon-a-16guanbi" onClick={backCar}></span>
                </div>
            </div>
            <hr></hr>
            <div className='content'>
                <div>
                    <div>
                        <div>
                            <Form {...layout} form={form} name="control-hooks" onFinish={onFinish}>
                                <Form.Item
                                    name="orName"
                                    label="组织名称"
                                    rules={[
                                        {
                                            required: true,
                                        },
                                    ]}
                                >
                                    <Select
                                        placeholder="请选择组织名称"
                                        allowClear
                                    >
                                        <Option value="乐清市">乐清市</Option>
                                        <Option value="市府办">市府办</Option>
                                        <Option value="经信局">经信局</Option>
                                        <Option value="组织部">组织部</Option>
                                        <Option value="统计局">统计局</Option>
                                        <Option value="发展改革处">发展改革处</Option>
                                        <Option value="办公室">办公室</Option>
                                        <Option value="企业科">企业科</Option>
                                        <Option value="经济运行科">经济运行科</Option>
                                        <Option value="数字化推进科">数字化推进科</Option>
                                        <Option value="产业人才科">产业人才科</Option>
                                        <Option value="投资机装科">投资机装科</Option>
                                        <Option value="宣传部">宣传部</Option>
                                        <Option value="文化部">文化部</Option>
                                    </Select>
                                </Form.Item>
                                <Form.Item
                                    name="orType"
                                    label="组织类型"
                                    rules={[
                                        {
                                            required: true,
                                        },
                                    ]}
                                >
                                    <Select
                                        placeholder="请选择组织类型"
                                        allowClear
                                    >
                                        <Option value="0">地区</Option>
                                        <Option value="1">部门</Option>
                                        <Option value="2">处室</Option>
                                    </Select>
                                </Form.Item>
                                <Form.Item
                                    name="orNum"
                                    label="组织编号"
                                    rules={[
                                        {
                                            required: true,
                                        },
                                    ]}
                                >
                                    <Input />
                                </Form.Item>
                                <Form.Item
                                    name="orCreatetime"
                                    label="创建时间"
                                // rules={[
                                //     {
                                //         required: true,
                                //     },
                                // ]}
                                >
                                    <DatePicker style={{ width: '100%' }} />
                                </Form.Item>
                                <Form.Item {...tailLayout}>
                                    <Button type="primary" htmlType="submit">
                                        提交
                                    </Button>
                                    <Button htmlType="button" onClick={quxiao} style={{ marginLeft: '20px' }}>
                                        取消
                                    </Button>
                                </Form.Item>
                            </Form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

}
export default OrgNew